﻿using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Oplug.CoolTower
{
    public partial class FormPrint : Form
    {
        public string ReportEmbResource { get; set; }
        public string ReportParam { get; set; }
        public string ReportName { get; set; }
        public DataTable dataSource { get; set; }
        public FormPrint(string _reportEmbResource, DataTable _dataSource, string _reportParam = "", string _reportName = "")
        {
            InitializeComponent();
            ReportEmbResource = _reportEmbResource;
            dataSource = _dataSource;
            ReportParam = _reportParam;
            ReportName = _reportName;
        }

        private void FormPrint_Load(object sender, EventArgs e)
        {
            reportViewerMain.LocalReport.DataSources.Clear();
            reportViewerMain.LocalReport.EnableExternalImages = true;
            reportViewerMain.LocalReport.ReportEmbeddedResource = ReportEmbResource;
            reportViewerMain.LocalReport.DataSources.Add(new ReportDataSource("DataSetReport", dataSource));
            if (!string.IsNullOrEmpty(ReportParam))
                reportViewerMain.LocalReport.SetParameters(new ReportParameter("ReportParam", ReportParam));
            reportViewerMain.LocalReport.SetParameters(new ReportParameter("Company", Utilities.CompName));
            if (!string.IsNullOrEmpty(ReportName))
                reportViewerMain.LocalReport.DisplayName = ReportName;
            reportViewerMain.RefreshReport();
            
        }

    }
}
